/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class HeartBeat implements MessagePayload{
	public int custom_mode;
	public byte type;
	public byte autopilot;
	public byte base_mode;
	public byte system_status;
	public byte mavlink_version;
	
	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putInt(custom_mode);
		bb.put(type);
		bb.put(autopilot);
		bb.put(base_mode);
		bb.put(system_status);
		bb.put(mavlink_version);
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		custom_mode = bb.getInt();
		type = bb.get();
		autopilot = bb.get();
		base_mode = bb.get();
		system_status = bb.get();
		mavlink_version = bb.get();
	}
}
